package cn.genmer.test.security.recordlog.util;

public class GeohashValidator {

    /**
     * Validates the given string as a geohash with a length between 6 and 12 characters.
     *
     * @param geohash the string to validate as a geohash
     * @return true if the string is a valid geohash, false otherwise
     */
    public static boolean isValidGeohash(String geohash) {
        // 正则表达式，匹配6到12位的字符串
        String regex = "^[0-9a-z]{6,12}$";
        return geohash != null && geohash.matches(regex);
    }

    public static void main(String[] args) {
        System.out.println("1" + "2" + null);
        // 测试用例
        String[] testCases = {
            "u4892q",       // 6位geohash
            "u4892qy",      // 7位geohash
            "u4892qy1",     // 8位geohash
            "u4892qy12",    // 12位geohash
            "123456789012", // 超过12位的字符串
            "geohash",      // 包含非字母数字字符的字符串
            null,           // 空字符串
            ""              // 空字符串
        };

        // 验证每个测试用例
        for (String geohash : testCases) {
            System.out.printf("Geohash '%s' is valid: %s%n", geohash, isValidGeohash(geohash));
        }
    }
}